<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<form action="#" name="forms">
		<label for="user">姓名</label><input type="text" placeholder="请输入姓名" id="user" autocomplete="off">
		<span id="tip"></span><br>
		<label for="tel">电话</label><input type="text" id="tel" placeholder="请输入电话" autocomplete="off" onkeyup="this.value=this.value.replace(/\D/gi,'')" onkeydown="this.value=this.value.replace(/\D/gi,'')" onpaste="return false"><br>
		<button>提交</button>
	</form>

	<script>
		document.forms.onsubmit=function(){
			var flag=true;
			if(user.value==''){
				flag=false;
				alert("请输入内容");
			}

			var oname=/^张三{1,}$/;
			user.value.match(oname);
			console.log(user.value.match(oname));

			var otel=/^[0-9]{11,11}$/;
			tel.value.match(otel);
			console.log(tel.value.match(otel));

			return flag;
		}

		user.onblur=function(){
			if(user.value==''){
				tip.innerHTML='请先输入姓名';
			}else tip.innerHTML='请输入电话';
		}


	</script>
</body>
</html>